package com.example.gallery;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.board.R;


public class AlbumListAdapter extends ArrayAdapter<AlbumDTO>{
	ArrayList<AlbumDTO> list;
	
	public AlbumListAdapter(Context context, int resource, ArrayList<AlbumDTO> list) {
		super(context, resource, list);
		this.list = list;
	}

	

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
		if(v == null){
			LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			
			v = vi.inflate(R.layout.album_row, null);
		}
		notifyDataSetChanged();
		AlbumDTO album = list.get(position);
		notifyDataSetChanged();
		
		
		if(album != null){
			ImageView iv_album = (ImageView) v.findViewById(R.id.iv_album);
			TextView tv_album_name = (TextView) v.findViewById(R.id.tv_album_name);
			TextView tv_album_count = (TextView) v.findViewById(R.id.tv_album_count);

//			iv_album.set(album.a_image+"");
			tv_album_name.setText(album.a_name);
			tv_album_count.setText(album.a_count+"");
		}
		return v;
	}
}
